package com.dd.demo.day2;

/**
 * 字符串处理
 *
 * @author wuzonglin
 * @version 0.1.0
 * @Date 2022/08/03
 * @Copyright 1998-2021 重庆鸥睿珂数字科技发展有限公司. All rights reserved. Power by DO&DonE®
 */
public class Test4 {

	public static void main(String[] args) {
		/*
		把如下文档字符串 解析 生成枚举代码枚举实例部分 类似如下
	TEMP("TEMP", "温度", "℃"),
	HUMI("HUMI", "温度", "%"),
	MPA("MPA", "气压", "hPa"),
	WD("WD", "风向", "风向"),
	WS("WS", "风速", "风速"),
	CO("CO", "一氧化碳", "mg/m³"),
	NO2("NO2", "二氧化氮", "μg/m³"),
	O3("O3", "臭氧", "μg/m³"),
	SO2("SO2", "二氧化硫", "μg/m³"),
	PM10("PM10", "pm10", "μg/m³"),
	PM25("PM25", "pm2.5", "μg/m³");
		 */
		String doc = "PM10\tPM10\tμg/m³\n" +
				"PM100\tPM100\tμg/m³\n" +
				"TEMP\t温度\t℃\n" +
				"HUMI\t湿度\t%\n" +
				"SO2\t二氧化硫\tμg/m³\n" +
				"NO2\t二氧化氮\tμg/m³\n" +
				"O3\t臭氧\tμg/m³\n" +
				"CO\t一氧化碳\tmg/m³\n" +
				"CO2\t二氧化碳\tμg/m³\n" +
				"VOC\tVOC\tμg/m³\n" +
				"CH2O\t甲醛\tμg/m³\n" +
				"O2\t氧气\t%VOL\n" +
				"MPA\t气压\thPa\n" +
				"WS\t风速\tm/s\n" +
				"WD\t风向\t°\n" +
				"NOISE\t噪声\tdB(A)\n" +
				"CL2\t氯气\tmg/m³\n" +
				"HCL\t盐酸\tmg/m³\n" +
				"H2S\t硫化氢\tμg/m³\n" +
				"NH3\t氨气\tμg/m³\n" +
				"NMHC\t非甲烷总烃\tμg/m³\n" +
				"PM25\tPM2.5\tμg/m³\n" +
				"TSP\tTSP\tμg/m³\n" +
				"WTHD\t硬度\tPPM\n" +
				"WTTBT\t浊度\tNTU\n" +
				"NOI\t负氧离子\t个/cm³\n" +
				"RAINFALL\t降雨量\tmm/min\n" +
				"LUX\t光照度\tLUX\n" +
				"NOX\tNOX\tmg/m";
		String[] rows = doc.split("\n");
		StringBuilder stringBuilder = new StringBuilder();
		for (String row : rows) {
			String[] infos = row.split("\t");
			// 编码
			String code = infos[0];
			// 名称
			String name = infos[1];
			// 计量单位
			String unit = infos[2];
			String linePrint = String.format("%s(\"%s\", \"%s\", \"%s\")", code, code, name, unit);
			System.out.println(linePrint);
			stringBuilder.append(linePrint).append(",\n");
		}
		stringBuilder.setLength(stringBuilder.length() - 2);
		stringBuilder.append(";\n");
		System.out.println("\n\n\n\n\n\n");
		System.out.println(stringBuilder);
	}
}
